package com.topisv.tms.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.topisv.tms.entity.BackupTaskOrdeno;

public interface BackupTaskOrdenoDao extends JpaSpecificationExecutor<BackupTaskOrdeno>,
		PagingAndSortingRepository<BackupTaskOrdeno, Long> {
	
	@Query("select bto from BackupTaskOrdeno bto,BackupTask bt where bt.customerCode=?1 and bto.backupTaskCode=bt.backupTaskCode and  bto.ordeno=?2")
	BackupTaskOrdeno findOrdeno(String customerCode,String ordeno);

	/**
	 * 根据拣货任务编号查询
	 * @param backupTaskCode
	 * @return
	 */
	List<BackupTaskOrdeno> findByBackupTaskCode(String backupTaskCode);
	
	List<BackupTaskOrdeno> findByBackupTaskCodeAndStatus(String backupTaskCode,String status);
	
	/**
	 * 根据出库批次编号查询
	 * @param batchCode
	 * @return
	 */
	List<BackupTaskOrdeno> findByBatchCode(String batchCode);
	
	/**
	 * 根据出库批次编号与订单装箱状态
	 * @param batchCode
	 * @param pickStatus
	 * @return
	 */
	List<BackupTaskOrdeno> findByBatchCodeAndPickStatus(String batchCode,String pickStatus);
	
	/**
	 * 根据出库批次编号与备货批次编号查询
	 * @param batchCode
	 * @param batchTaskCode
	 * @return
	 */
	List<BackupTaskOrdeno> findByBatchCodeAndBatchTaskCode(String batchCode,String batchTaskCode);
	
	/**
	 * 根据拣货任务编号与批次任务编号查询
	 * @param backupTaskCode
	 * @param batchTaskCode
	 * @return
	 */
	List<BackupTaskOrdeno> findByBackupTaskCodeAndBatchTaskCode(String backupTaskCode,String batchTaskCode);
	
	/**
	 * 根据订单号查询
	 * @param ordeno
	 * @return
	 */
	BackupTaskOrdeno findByOrdeno(String ordeno);
	
	BackupTaskOrdeno findByWaybillNo(String waybillNo);
	
	/**
	 * 根据备货批次号查询
	 * @param batchTaskCode
	 * @return
	 */
	List<BackupTaskOrdeno> findByBatchTaskCode(String batchTaskCode);
	
	BackupTaskOrdeno findByBatchTaskCodeAndOrdeno(String batchTaskCode,String ordeno);
	
}
